package teamproject.visualization.gui;

import java.awt.AWTEvent;
import java.awt.event.KeyEvent;

public class SpaceBarProcessor {

	private boolean stop = true;
	private KeyEvent eventKey;

	public SpaceBarProcessor() {
	}

	public boolean hasStopped() {
		return stop;
	}

	public void processAWTEvents(AWTEvent[] events) {
		int keyCode;

		for (int i = 0; i < events.length; i++) {
			if (events[i] instanceof KeyEvent) {
				eventKey = (KeyEvent) events[i];
				if (eventKey.getID() == KeyEvent.KEY_PRESSED) {
					keyCode = eventKey.getKeyCode();
					if (keyCode == KeyEvent.VK_SPACE) {
						if (stop)
							stop = false;
						else if (!stop)
							stop = true;
					}
				}
			}
		}
	}

	public void setStop(boolean stop) {
		this.stop = stop;
	}
}
